<?php
/**
 * Created by PhpStorm.
 * User: jiangxiaobo
 * Date: 2019/11/11 0011
 * Time: 19:00
 */
namespace bootstrap\lib\traits;

trait Singleton
{
    private static $instance = null;

    public static function getInstance()
    {
        if(!isset(self::$instance)){
            self::$instance = new static();
        }
        return self::$instance;
    }

    // 私有构造方法，只能在类中创建对象
    private function __construct(){}
    // 阻止用户复制对象创建脚本
    private function __clone(){}
}
